package chapter8.poly_.Exercise;

public class PloyExercise {
    public static void main(String[] args) {
        Sub s = new Sub();
        System.out.println(s.count);//属性看编译类型
        s.disPlay();//方法看运行类型，从运行类型开始逐层向上查找
        Base b = s;//向上转型
        System.out.println(b.count);
        b.disPlay();
    }
}

class Base {//父类
    int count = 10;

    public void disPlay() {
        System.out.println(this.count);

    }
}

class Sub extends Base {
    int count = 20;

    public void disPlay() {
        System.out.println(this.count);
    }
}